package com.nidu.demo.common.enums;

import cn.hutool.core.util.ArrayUtil;
import com.nidu.demo.common.validation.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum NoticeTypeEnum implements IntArrayValuable {

    /**
     * 注意事项
     */
    NOTICE(1, "通知"),

    /**
     * 公告
     */
    ANNOUNCEMENT(2, "公告");

    /**
     * 类型
     */
    private final Integer type;

    /**
     * 描述
     */
    private final String desc;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(NoticeTypeEnum::getType).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static NoticeTypeEnum of(Integer val) {
        return ArrayUtil.firstMatch(o -> o.getType().equals(val), values());
    }
}
